import mongoose, { Document, Schema } from 'mongoose';
import { ITeam } from './Team'; // 交叉引用类型

export interface IWork extends Document {
  title: string;
  description: string;
  thumbnailUrl?: string;
  team: ITeam['_id'];
  downloadUrl?: string;
  githubUrl?: string;
  tags?: string[];
  status: 'pending' | 'approved' | 'rejected';
}

const WorkSchema: Schema = new Schema({
  title: { type: String, required: true },
  description: { type: String, required: true },
  thumbnailUrl: { type: String },
  team: { type: Schema.Types.ObjectId, ref: 'Team', required: true },
  downloadUrl: { type: String },
  githubUrl: { type: String },
  tags: [{ type: String }],
  status: { type: String, enum: ['pending', 'approved', 'rejected'], default: 'pending' }
}, { timestamps: true });

export default mongoose.model<IWork>('Work', WorkSchema);